import {fetchHotGoodsApi} from '@/apis/detail.js'
import {ref,onMounted} from 'vue'
import { useRoute , onBeforeRouteUpdate} from 'vue-router'

export function useHotList() {

  const route = useRoute()
  const id =route.params.id

  let HotGoods = ref([])
  const GetHotGoods = async(id = route.params.id , type = 1) => {
      const res = await fetchHotGoodsApi(id,type)
      console.log(res.result)
      HotGoods.value = res.result
  }




  // onBeforeRouteUpdate((to) => {
  //   console.log(to.params.id)
  //   GetHotGoods(to.params.id)
  // })

  return {HotGoods,id,GetHotGoods}
}
